import http from '@/utils/http.js'

export function loginAPI(params, data) {
    console.log('data: ', data);
    return http({
        url: '/admin/api/user/login',
        method: 'post',
        params,
        data
    })
}

export const getVCodeKey = (params = {}) => {
    return http({
        url: '/admin/api/user/getVCodeKey',
        method: 'get',
        params
    })
}

export const getVCode = (params = {}) => {
    return http({
        url: '/admin/api/user/getVCode',
        method: 'get',
        params,
        responseType: 'blob', // 响应类型
    })
}

export const sendCode = (params = {}) => {
    return http({
        url: '/admin/api/register/send-code',
        method: 'post',
        params
    })
}

export const register = (data) => {
    return http({
        url: '/admin/api/register',
        method: 'post',
        data
    })
}

export const logOut = () => {
    return http({
        url: '/admin/api/user/logout',
        method: 'post',
    })
}

export function getLikeListAPI({ limit = 4 }) {
    return http({
        url: '/api/goods/relevant',
        method: 'get',
        params: {
            limit
        }
    })
}

export function getUserOrderAPI(userId) {
    return http({
        url: `/order/api/order/getByUserId/${userId}`,
        method: 'get',
        // params
    })
}


export function getUserAddressAPI(uid) {
    return http({
        url: `/order/api/address/getByUid/${uid}`,
        method: 'get'
    })
}


export function updateUserAddressAPI(id, data) {
    return http({
        url: `/order/api/address/updateAddress/${id}`,
        method: 'POST',
        data
    })
}

export function createUserAddressAPI(data) {
    return http({
        url: '/order/api/address/addAddress',
        method: 'POST',
        data
    })
}

export function deleteUserAddressAPI(id) {
    return http({
        url: `/order/api/address/deleteAddress/${id}`,
        method: 'get',
    })
}


export const getUserInfoAPI = (params) => {
    return http({
        url: '/admin/api/user/info',
        method: 'get',
        params
    })
}

